package controller;

import entity.Lin;
import entity.Supplier;
import org.omg.PortableInterceptor.SUCCESSFUL;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import service.SupplierService;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/supp")
public class SupplierCon {
    @Resource(name="supplierService")
    private SupplierService supplierService;

    @RequestMapping("/query")
    @ResponseBody
    public List<Supplier> list(){
        return supplierService.list();
    }

    @RequestMapping("/Qtiaozhuan")
    public String tiaozhuan(Model model) {
        return "WEB-INF/jsp/xitongshezhi/gongyingshangshezhi";
    }
    @RequestMapping("/Qtianjia")
    @ResponseBody
    public List<Supplier> add2(Supplier supplier){
        Supplier supplier1=new Supplier();

        int s=supplierService.Qadd(supplier);

        return supplierService.list();

    }
    @RequestMapping("/Qxiugai")
    @ResponseBody
    public List<Supplier> Qupd(Supplier supplier){
        Supplier supplier1=new Supplier();
        int s=supplierService.Qupd(supplier);
        return  supplierService.list();
    }
    @RequestMapping("/Qdel")
    @ResponseBody
    public List<Supplier> Qdel(Supplier supplier){
        Supplier supplier1=new Supplier();
        int s=supplierService.Qdel(supplier);
        return supplierService.list();

    }

    @RequestMapping("/Qlist")
    @ResponseBody
    public List<Supplier> Qlist(String name){
        Supplier supplier=new Supplier();
        supplier.setName(name);
        Map<String, Object> mapResult = new HashMap<String, Object>();

        mapResult.put("name",name);
        List<Supplier> suppliers=supplierService.Qlist(mapResult);
        return suppliers;

    }
}
